Function.prototype.myBind = function (context, ...args) {
  if (typeof this !== 'function') {
    throw new TypeError('Error')
  }
  const _this = this
  // 返回函数
  return function F() {
    // 1 判断是否用作构造函数；new F()时，this instanceof F
    if (this instanceof F) {
      return new _this(...args, ...arguments)
    }
    // 2 用作普通函数
    return _this.apply(context, [...args, ...arguments])
  }
}

function print(a, b, c) {
  console.log('this:', this.val, a, b, c)
}

const obj = { val: 11 }
obj.print = print
obj.print()

const obj2 = { val: 'SSSS' }

obj.print.myBind(obj2)(1, 2, 3)
